package com.zc.app;

import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.value.ObservableValue;

/**
 * Created by CZC70 on 2017/5/23.
 */
public class ChangeTest {

    public static void main(String[] args){
        IntegerProperty counter = new SimpleIntegerProperty(100);

        counter.addListener(ChangeTest::changed);

        System.out.println("\nBefore changing the counter value -1");
        counter.set(101);
        System.out.println("After changing the counter value -1");

        System.out.println("\nBefore changing the counter value -1");
        counter.set(102);
        System.out.println("After changing the counter value -1");
    }

    public static void changed(ObservableValue<? extends Number> prop,
                               Number oldValue, Number newValue) {
        System.out.print("Counter changed: ");
        System.out.println("Old = " + oldValue + ", new = " + newValue);
    }
}
